package com.acme.entity;

import com.acme.entity.util.EntityBean;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author alejandro
 */
@Entity
@Table(name = "ENTRONQUE", catalog = "carreteras", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Entronque.findAll", query = "SELECT e FROM Entronque e"),
    @NamedQuery(name = "Entronque.findById", query = "SELECT e FROM Entronque e WHERE e.id = :id"),
    @NamedQuery(name = "Entronque.findByKilometro", query = "SELECT e FROM Entronque e WHERE e.kilometro = :kilometro")})
public class Entronque extends EntityBean<Entronque> {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "kilometro", length = 15)
    private String kilometro;
    @JoinColumn(name = "tramo", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Tramo tramo;

    public Entronque() {
    }

    public Entronque(Integer id) {
        this.id = id;
    }

    public Entronque(Integer id, String kilometro, Tramo tramo) {
        this.id = id;
        this.kilometro = kilometro;
        this.tramo = tramo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
        support.fireChange();
    }

    public String getKilometro() {
        return kilometro;
    }

    public void setKilometro(String kilometro) {
        this.kilometro = kilometro;
        support.fireChange();
    }

    public Tramo getTramo() {
        return tramo;
    }

    public void setTramo(Tramo tramo) {
        this.tramo = tramo;
        support.fireChange();
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Entronque)) {
            return false;
        }
        Entronque other = (Entronque) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return String.format("Entronque: km%s (%s)", kilometro, tramo);
    }

    @Override
    public Entronque clone() {
        return new Entronque(id, kilometro, tramo);
    }

    @Override
    public void merge(Entronque other) {
        this.id = other.id;
        this.kilometro = other.kilometro;
        this.tramo = other.tramo;
    }

}
